package com.hjqjl.module_choice.ui;

import android.content.Context;
import android.content.Intent;

import com.blankj.utilcode.util.ToastUtils;
import com.hjqjl.module_choice.databinding.ChoiceActivityCountDownBinding;
import com.hjqjl.module_choice.utils.CountDownButtonHelper;
import com.hjqjl.whapplib.base.BaseActivity;

/**
 * 倒计时按钮
 */
public class CountDownActivity extends BaseActivity<ChoiceActivityCountDownBinding> {
    public static void start(Context context) {
        Intent intent = new Intent(context, CountDownActivity.class);
        context.startActivity(intent);
    }

    private CountDownButtonHelper countDownButtonHelper;

    @Override
    public void initData() {
        setTitle("倒计时");
        countDownButtonHelper = new CountDownButtonHelper(pVBinding.choiceBtnCountDown);
    }

    @Override
    public void initListener() {
        pVBinding.choiceBtnCountDown.setOnClickListener(v -> countDownButtonHelper.start());
        countDownButtonHelper.setOnFinishListener(() -> ToastUtils.showShort("倒计时结束调用"));
    }

    @Override
    protected void onDestroy() {
        if (null != countDownButtonHelper) {
            countDownButtonHelper.cancel();
        }
        super.onDestroy();
    }
}
